<template>
	<view>
		<!-- <uni-nav-bar left-icon="back" @clickLeft="goBack" @clickRight="backRight" right-text="搜索" title="保养"></uni-nav-bar> -->
		<view class="">
			<v-tabs v-model="activeTab" bgColor="#F0F3F6" :fixed="true" :lineScale="0.2" :scroll="false" :tabs="tabs" activeFontSize="32rpx" fontSize="30rpx"  @change="changeTab"></v-tabs>
			
		</view>
		<!-- 内容  待保养-->
		<view class="" v-show="activeTab == indexs">
			<block v-if="recordList.length > 0">
				<uni-card v-for="(item,index) in recordList" :key="index">
					<view class="record" @click="verticalLadder(item.upkeepId)">
						<view class="record-address">
							{{item.elevatorName}}
							<text v-if="item.upkeepType == 1">[半月]</text>
							<text v-if="item.upkeepType == 2">[季度]</text>
							<text v-if="item.upkeepType == 3">[半年]</text>
							<text v-if="item.upkeepType == 4">[年度]</text>
						</view>
						<view class="" v-if="indexs == 1">提交人：{{item.referUser}}</view>
						<view class="information disali">
							<!-- left -->
							<view class="information-left">
								<view class="record-time">
									截止时间:
									<text>{{item.overTime}}</text>
								</view>
							</view>
							<!-- 待保养 right-->
							<view class="successMaintain backc5 disali" v-if="indexs == 0">
								<image src="../../../static/img/detailsMsg/time.png" mode=""></image>
								<!-- <uni-icons type="success"></uni-icons> -->
								<view class="handleMaintain">
									<text>待保养</text>
								</view>
							</view>
							<view class="successMaintain backd5 disali" v-if="indexs == 1">
								<image src="../../../static/img/detailsMsg/time.png" mode=""></image>
								<!-- <uni-icons type="success"></uni-icons> -->
								<view class="handleMaintain">
									<text>待确认</text>
								</view>
							</view>
						</view>

					</view>
				</uni-card>
			</block>
			<block v-else>
				<nullPage></nullPage>
			</block>
		</view>
	</view>
</template>

<script>
	import nullPage from '@/common/null.vue' //选择器值 
	import toMaintain from "@/serve/api/toMaintain.js"
	export default {
		components: {
			nullPage
		},
		data() {
			return {
				activeTab: 0,
				tabs: ['待保养', '待确认', '已完成'],
				pageNum: 1,
				recordList: [],
				indexs: 0,
			}
		},
		onLoad() {
			this.getrecordList();
		},
		methods: {
			// 导航返回事件
			goBack() {
				uni.switchTab({
					url: "../../tabbar/work/work"
				})
			},
			// 导航右边事件
			backRight() {
				uni.switchTab({
					url: ""
				})
			},
			changeTab(index) {
				this.indexs = index
				this.pageNum = 1
				this.recordList = []
				this.getrecordList()
			},
			// 待确定页面跳转到保养完成
			gomaintainOver() {
				uni.navigateTo({
					url: "../verticalLadder/verticalLadder?elevatorId="
				})
			},
			// 待保养，接口
			async getrecordList() {
				console.log(this.indexs)
				let parme = {
					pageNum: this.pageNum,
					pageSize: 10,
					reviewType: this.indexs,
				}
				const res = await toMaintain.selectUpkeepAuditList(parme)
				this.recordList = this.recordList.concat(res.data.data.list)
				if (res.data.data.list.length < 10 && this.recordList.length > 0) {
					uni.showToast({
						title: '已加载全部',
						icon: 'none'
					})
				} else if (res.data.data.list == []) {
					uni.showToast({
						title: '暂无数据',
						icon: 'none'
					})
				}
			},
			async verticalLadder(e) {
				
				// if (res) {
					if (this.indexs == 0) {
						let parme = {
							upkeepId: e,
						}
						const res = await toMaintain.startUpkeep(parme)
						if(res){
							uni.navigateTo({
								url: "/pages/gird/verticalLadder/verticalLadder?upkeepId=" + e
							})
						}
						
					}
					if (this.indexs == 1) {
						uni.navigateTo({
							url: "/pages/gird/verticalLadder/verticalLadder_affirm?upkeepId=" + e
						})
					}
					if (this.indexs == 2) {
						uni.navigateTo({
							url: "/pages/gird/verticalLadder/verticalLadder_perform?upkeepId=" + e
						})
					}
				// }

			}
		},
		onReachBottom(e) {
			this.pageNum = this.pageNum + 1;
			this.getrecordList();
		}
	}
</script>

<style scoped>
	.uni-icons {
		color: #3AC211;
	}

	.disali {
		display: flex;
		align-items: center
	}

	.backc5 {
		background-color: #ADB5C5;
	}

	.backd5 {
		background-color: #65D0D5;
	}

	.uni-card {
		width: 670rpx;
		/* height: 280rpx; */
		background: #FFFFFF;
		/* box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05); */
		border-radius: 16rpx;
		margin: 0 auto;
		margin-top: 20rpx;
		border: none;
		line-height: 280rpx;
		text-align: left;
	}

	.record {
		font-family: PingFang SC;
		font-weight: 400;
		/* margin: 40rpx 0; */
	}

	.record-address {
		font-size: 30rpx;
		color: #34363D;
		display: flex;
		justify-content: space-between;
		margin-bottom: 30rpx;
	}

	.record-address text {
		color: #017EFE;
	}

	.record-state {
		font-size: 30rpx;
		color: #017EFE;
	}

	/* 左右 信息*/
	.information {
		display: flex;
		justify-content: space-between;
		/* align-items: center; */
		flex-wrap: nowrap;
		margin-top: 10rpx;

	}

	.record-time {
		font-size: 24rpx;
		color: #989BA6;
	}

	.record-time text {
		margin-left: 15rpx;
		color: #34363D;
		word-spacing: 15rpx;
		letter-spacing: 1rpx;
	}

	/* 待确认 */
	.successState {
		background: #65D0D5;
		width: 150rpx;
		height: 60rpx;
		text-align: center;
		/* box-shadow: 0px 5px 10px 0px rgba(58, 194, 17, 0.2); */
		border-radius: 28rpx;
		color: #FFFFFF;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.successState image {
		width: 30rpx;
		height: 30rpx;
		background: #65D0D5;
		border-radius: 10rpx;
		vertical-align: middle;
	}

	.successState text {
		font-size: 24rpx;
		margin-left: 10rpx;
	}

	/* 待保养 */
	.successMaintain {
		width: 150rpx;
		height: 60rpx;
		text-align: center;
		/* box-shadow: 0px 5px 10px 0px rgba(58, 194, 17, 0.2); */
		border-radius: 28rpx;
		color: #FFFFFF;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.successMaintain image {
		width: 30rpx;
		height: 30rpx;
		/* background: #65D0D5; */
		border-radius: 10rpx;
		vertical-align: middle;
	}

	.successMaintain text {
		font-size: 24rpx;
		margin-left: 10rpx;
	}

	/* 已完成 */
	.successAccomplish {
		background-color: #3AC211;
		width: 150rpx;
		height: 60rpx;
		text-align: center;
		/* box-shadow: 0px 5px 10px 0px rgba(58, 194, 17, 0.2); */
		border-radius: 28rpx;
		color: #FFFFFF;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.successAccomplish image {
		width: 30rpx;
		height: 30rpx;
		border-radius: 10rpx;
		vertical-align: middle;
	}

	.successAccomplish text {
		font-size: 24rpx;
		margin-left: 10rpx;
	}

	.v-tabs__container {
		background: RGBA(240, 243, 246, 1) !important;
	}
</style>
